define(["require",
	'config/appregister',
	"business/Companyinfor/service/htttp",
	"business/services/filter",
	"jquery",
	'business/services/cutPicture',
	"business/workSkill/directive/startLevel",
	"upfull",
	"business/Companyinfor/directive/upload1",
"business/Companyinfor/directive/upload2",
"business/Companyinfor/directive/upload3",
"business/Companyinfor/directive/upload4",
"business/Companyinfor/directive/upload5",], function(require, app, httpServices) {
	app.controller('accountCtrl', function($scope, $timeout) {

		function getCOmpany(){
			var req ={
			 type:"GET",
			 uri:"getBaseInfoByUser",
			 data:{}
		 };
			 httpServices.homePageHttpService(req).success(function(result){
			 $scope.$apply(function(){
				$scope.companyId = result.data.companyId;
			 })
		 });
		            
		}
		getCOmpany();
		$scope.$on('previewPath',function(a,b,c){
			$scope.imgArr[b[0]] = b[1];
		})
		
		var ip = "http://"+allUrl+":8080";
		var pswdurl = "/elink_user/api/user/modifyPasswd";
		var newemail = getQueryString("email");
		var verifyCode = getQueryString("verifyCode");
		var verifyToken = getQueryString("verifyToken");

		if(newemail !== "" && verifyCode !== "" && verifyToken !== "") {
			
			var req ={
                type:"POST",
                uri:"modifyEmailWithCheckNewPhoneCode",
                data:{
                    verifyToken: verifyToken,
					newEmail: newemail,
					verifyCode: verifyCode
                }
            };
            httpServices.getuser(req).success(function(data){
                $scope.$apply(function(){
                   if(data.code == 0) {
						console.log("修改邮箱成功");
						$(".modemlokbox").show();
						$(".myaccount-center-top li:nth-child(1)").attr("id", "");
						$(".myaccount-center-top li:nth-child(2)").attr("id", "mya-c-t-btn");
						$(".myaccount-center-top li:nth-child(3)").attr("id", "");
						$(".user-security").show();
						$(".a-infor").hide();
						$(".myaccount-center-c").hide();
					} else {
						console.log(data.msg);
					}

                })
            });

		} else {
//			console.log("重定向第一次渲染有空参数");
		};
		
		//渲染企业档案
		getFile();
		//跳转
		$scope.topgo = function(num) {
			if(num == 1) {
				$state.go("myMainPage");
			}
			if(num == 2) {
				$state.go("bloglist");
			}
			if(num == 3) {
				$state.go("resume");
			}
			if(num == 4) {
				$state.go("homepage");
			}
		};
		
		//邮箱 点击修改
		$scope.openemailmoddiv = function() {
			$(".modifyemail-onebox").show();
			getimg();
		};
		//修改邮箱第一步，请求图片验证码	
		function getimg() {
			var req = {
				type:'get',
				uri:'modifyEmailWithVerifyCode'
			};
			httpServices.getuserHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code==0) {
						$scope.imgsrc = data.data.img;
						var arr = data.data.verifyToken;
						var arred = arr.split(",");
						$scope.verifyToken = arred[0];
						var expireTime = arred[1];
						var exp = new Date();
						exp.setTime(exp.getTime() + expireTime);
						document.cookie = "verifyToken=" + $scope.verifyToken + ";expires=" + exp.toGMTString();
					}else {
						console.log(data.msg);
					}
				})
			}).error(function(){
				console.log("修改邮箱第一步请求失败");
			});
		};
		
		//关闭 邮箱第一个box
		$scope.offonebox = function() {
			$(".modifyemail-onebox").hide();
		};
		//点击获取短信验证码
		$scope.getmsgcode = function() {
			getemlphonecode();
		};

		function getemlphonecode() {
			var u = "/elink_user/api/user/modifyEmailWithSendPhoneCode";
			var href = window.location.href;
			var phone = $("#onebox-input1").val();
			var code = $("#onebox-input2").val();
			if(phone !== "" && code !== "") {	
				var req ={
		                type:"POST",
		                uri:"modifyEmailWithSendPhoneCode",
		                data:{
		                    phone: phone,
							verifyCode: code,
							verifyToken: $scope.verifyToken
		                }
		            };
		            httpServices.getuser(req).success(function(data){
		                $scope.$apply(function(){
		                	//倒计时重新获取动作
							if(data.code == 0) {
								$("#blue").html("");
								$('#blue').unbind("click");
								$("#blue").html("重新获取(<span id=" + 'time' + ">60</span>)");
								var timer = $("#time").html();
								var mytime = setInterval(function() {
									if(timer > 0) {
										timer--;
										timer = timer;
									} else {
										clearInterval(mytime);
										$("#blue").html("重新获取");
										$('#blue').bind("click");
										getimg();
									}
									$("#time").html(timer);
								}, 1000)
							} else {
								alert(data.msg);
								getimg();
							}
		
		                })
		            });	
			} else {
				alert("请填写完整手机号/图片验证码，再点击获取验证码按钮");
			}
		};
		
		//第一个邮箱盒子点击验证身份
		$scope.checkId = function() {
			emailcheckId();
		}

		function emailcheckId() {
			var u = "/elink_user/api/user/modifyEmailWithCheckPhoneCode";
			var phone = $("#onebox-input1").val();
			var code = $("#onebox-input3").val();
			if(phone !== "" && code !== "") {
				var req ={
		                type:"POST",
		                uri:"modifyEmailWithCheckPhoneCode",
		                data:{
	                    	phone: phone,
							verifyCode: code
		                }
		            };
		            httpServices.getuser(req).success(function(data){
		                $scope.$apply(function(){
		                   	if(data.code == 0) {
								console.log("获取短信验证码成功");
							} else {
								console.log(data.msg);
							}
		
		                })
		            });	
			} else {
				console.log("有空参数")
			}

		};

		//获取邮箱box2的图片验证码
		$scope.getbox2pic = function() {
			getbox2img();
		}

		function getbox2img() {
			var num = Math.round(Math.random() * 10);
			var u = ip + "/elink_user/api/user/modifyEmailWithNewVerifyCode?i=" + new Date();
			document.getElementById("emailpic").setAttribute("src", u + num);
		}
		//
		//
		//
		//点击绑定新邮箱
		$scope.bindNewEmail = function() {
			bindneweml();
		}

		function bindneweml() {
			var u = "/elink_user/api/user/modifyEmailWithSendNewPhoneCode";
			var href = window.location.href;
			var newemail = $("#newEmail").val();
			var code = $("#newCode").val();
			if(href !== "" && newemail !== "" && code !== "") {
				var req ={
		                type:"POST",
		                uri:"modifyEmailWithSendNewPhoneCode",
		                data:{
	                    	redirectUrl: href,
							newEmail: newemail,
							verifyCode: code
		                }
		            };
		            httpServices.getuser(req).success(function(data){
		                $scope.$apply(function(){
		                   	if(data.code == 0) {
								console.log("邮箱绑定请求成功");
								$(".emailmoddiv").hide();
								$(".cdxbox").show();
							} else {
								console.log(data.msg);
							}
		
		                })
		            });	
			} else {
				console.log("有空参数")
			}
		};

		//
		//重定向后验证
		function getQueryString(name) {
			// 如果链接没有参数，或者链接中不存在我们要获取的参数，直接返回空 
			if(location.href.indexOf("?") == -1 || location.href.indexOf(name + '=') == -1) {
				return '';
			}

			// 获取链接中参数部分 
			var queryString = location.href.substring(location.href.indexOf("?") + 1);

			// 分离参数对 ?key=value&key2=value2 
			var parameters = queryString.split("&");

			var pos, paraName, paraValue;
			for(var i = 0; i < parameters.length; i++) {
				// 获取等号位置 
				pos = parameters[i].indexOf('=');
				if(pos == -1) {
					continue;
				}
				// 获取name 和 value 
				paraName = parameters[i].substring(0, pos);
				paraValue = parameters[i].substring(pos + 1);

				// 如果查询的name等于当前name，就返回当前值，同时，将链接中的+号还原成空格 
				if(paraName == name) {
					return unescape(paraValue.replace(/\+/g, " "));
				}
			}
			return '';
		};

		//
		$scope.clickok = function() {
			$(".ok").hide();
		};
		$scope.onpswddiv = function() {
			$(".pswdmoddiv").hide();
		};
		$scope.onemailmoddiv = function() {
			$(".emailmoddiv").hide();
		};
		$scope.openphonemoddiv = function() {
			$(".phonemoddiv").show();
			modifygetpic();
		};
		$scope.onphonemoddiv = function() {
			$(".phonemoddiv").hide();
		};
		$scope.modpswdbtn = function() {
			$(".pswdmoddiv").show();
		};
		
		//个人账户安全 修改密码
		$scope.pswdmod = function() {
				var pswd1 = $("#pswd1").val();
				var pswd2 = $("#pswd2").val();
				var pswd3 = $("#pswd3").val();
				if(pswd2 !== pswd3) {
					$(".pswdtip").show().html("两次输入不一致");
					return false;
				}
				if(pswd2 == pswd3 && pswd1 !== "" && pswd2 !== "" && pswd3 !== "") {
					
					var req ={
				                type:"POST",
				                uri:"modifyPasswd",
				                data:{
			                    	passwd: pswd1,
									newPasswd: pswd2
				                }
				            };
				            httpServices.getuser(req).success(function(data){
				                $scope.$apply(function(){
				                  if(data.code == 0) {
									console.log("修改密码成功");
									$(".ok").show();
									$(".pswdmoddiv").hide();
									$(".pswdtip").hide();
								} else {
									console.log(data.msg);
								}
				
				                })
				            });	
				} else {

					$(".pswdtip").show().html("输入错误！请检查");
				}
		};
		
		//修改手机号流程一 
		$scope.clickimg = function() {
			modifygetpic();
		};

		function modifygetpic() {
			var req = {
				type:'get',
				uri:'modifyPhoneWithVerifyCode'
			};
			httpServices.getuserHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code==0) {
						$scope.phoneimgsrc = data.data.img;
						var arr = data.data.verifyToken;
						var arred = arr.split(",");
						$scope.verifyToken = arred[0];
						var expireTime = arred[1];
						var exp = new Date();
						exp.setTime(exp.getTime() + expireTime);
						document.cookie = "verifyToken=" + $scope.verifyToken + ";expires=" + exp.toGMTString();
					}else {
						console.log(data.msg);
					}
				})
			}).error(function(){
				console.log("修改手机号第一步请求失败");
			});			
			
			
			var num = Math.round(Math.random() * 10);
			var u = ip + "/elink_user/api/user/modifyPhoneWithVerifyCode?i=" + new Date();
			document.getElementById("modifyimg").setAttribute("src", u + num);
		};

		//修改邮箱流程一
		$scope.clickimg2 = function() {
			modifygetpic2();
		};

		function modifygetpic2() {
			var num = Math.round(Math.random() * 10);
			var u = ip + "/elink_user/api/user/modifyEmailWithVerifyCode?i=" + new Date();
			document.getElementById("emailpic").setAttribute("src", u + num);
		};

		//修改邮箱流程二
		$scope.dothebtn = function() {
			getphoneverifycode();
		};

		function getphoneverifycode() {
			var codeurl = "/elink_user/api/user/modifyPhoneWithSendPhoneCode";
			var phone = $(".nowphone").val();
			var verifycode = $(".piccodo").val();

			if(phone !== "" && verifycode !== "") {
				
				var req ={
	                type:"POST",
	                uri:"modifyPhoneWithSendPhoneCode",
	                data:{
                    	phone: phone,
						verifyCode: verifycode
	                }
	            };
	            httpServices.getuser(req).success(function(data){
	                $scope.$apply(function(){
	                  if(data.code == 0) {
							console.log("去看手机，等短信")
						} else {
							console.log(data.msg)
						}
	
	                })
	            });	
			} else {
				console.log("参数为空")
				return false;
			}

		};
		
		//修改手机第三步
		$scope.verifyid = function() {
			phonethree();
		};

		function phonethree() {
			var phonethreeurl = "/elink_user/api/user/modifyPhoneWithCheckPhoneCode";
			var phone = $(".nowphone").val();
			var msgcode = $(".phonecode").val();

			if(phone !== "" && msgcode !== "") {
				
				var req ={
	                type:"POST",
	                uri:"modifyPhoneWithCheckPhoneCode",
	                data:{
                    	phone: phone,
						verifyCode: msgcode
	                }
	            };
	            httpServices.getuser(req).success(function(data){
	                $scope.$apply(function(){
	                  if(data.code == 0) {
							console.log("找回成功跳转新手机box");
							$(".phonemoddiv").hide();
							$(".newphonediv").show();
							newImg();
						} else {
							console.log(data.msg)
						}
	
	                })
	            });	
			} else {
				console.log("参数为空");
				return false;
			}
		};
		
		//新手机box图片验证码
		function newImg() {
			var num = Math.round(Math.random() * 10);
			var u = ip + "/elink_user/api/user/modifyPhoneWithNewVerifyCode?i=" + new Date();
			document.getElementById("newimg").setAttribute("src", u + num);
		}

		//改手机第六步
		function lastnewphone() {
			var lasturl = "/elink_user/api/user/modifyPhoneWithCheckNewPhoneCode";
			var newphone = $(".newphonenum").val();
			var newphoneverifycode = $(".newphoneverifycode").val();

			if(newphone !== "" && newphoneverifycode !== "") {
				
				var req ={
	                type:"POST",
	                uri:"modifyPhoneWithCheckNewPhoneCode",
	                data:{
                    	newPhone: newphone,
						verifyCode: newphoneverifycode
	                }
	            };
	            httpServices.getuser(req).success(function(data){
	                $scope.$apply(function(){
	                  if(data.code == 0) {
							console.log("第六步请求成功")
							$(".newphonediv").hide();
							$(".newphoneok").show();
						} else {
							console.log(data.msg)
						}
	
	                })
	            });	
			} else {
				console.log("有空参数")
			}

		};

		//新手机号box点击获取短信验证码
		$scope.getphoneverifycode = function() {
			bindnewphone()
		}

		//新手机号box 点击最后的绑定新手机号按钮 
		$scope.bindnewphone = function() {
				lastnewphone();
			}
			//点击关闭第7步成功box
		$scope.onok = function() {
			$(".newphoneok").hide();
		}

		//改手机第5步 
		function bindnewphone() {
			var bindurl = "/elink_user/api/user/modifyPhoneWithSendNewPhoneCode";
			var newphone = $(".newphonenum").val();
			var newphonepiccode = $(".newphonecodepic").val();

			if(newphone !== "" && newphonepiccode !== "") {
				
				var req ={
	                type:"POST",
	                uri:"modifyPhoneWithSendNewPhoneCode",
	                data:{
                    	newPhone: newphone,
						verifyCode: newphonepiccode
	                }
	            };
	            httpServices.getuser(req).success(function(data){
	                $scope.$apply(function(){
	                 if(data.code == 0) {
							console.log("第五步成功")
						} else {
							console.log(data.msg)
						}
	                })
	            });	
			} else {
				console.log("参数为空")
			}

		};

		
		//不知道是什么东西
		$scope.bgColor = 5;
		//寿云山开始
		//企业档案
		function getFile() {
			var req = {
				type: "GET",
				uri: "getCurrentCompanyInfo",
				data: {
					companyId:$scope.companyId
				}
			};
			httpServices.homePageHttpService(req).success(function(response) {
				if(!response)return;
				$scope.$apply(function() {
					$scope.companyFile = {
						scaleId: response.data.scaleId,
						guildId: response.data.guildId,
						style: response.data.style,
						time: response.data.foundTime,
						logo: response.data.logo,
						shortName: response.data.shortName,
						natureId: response.data.natureId,
						provinceId: response.data.provinceId,
						regionId: response.data.regionId,
						areaId: response.data.areaId,
						address: response.data.address,
						postcode: response.data.postcode,
						fullName: response.data.fullName,
						website: response.data.website,
						description: response.data.description,
						introduction: response.data.introduction,
						companyStyle: response.data.style.split(','),
						legalPerson: response.data.legalPerson,
						department: response.data.department,
						job: response.data.job,
						telPhone: response.data.telPhone,
						mobilePhone: response.data.mobilePhone
					};
					getscale($scope.companyFile.scaleId);
					getguild($scope.companyFile.guildId);
					getNature($scope.companyFile.natureId);
					getprovince($scope.companyFile.provinceId);
					getCity($scope.companyFile.provinceId, $scope.companyFile.regionId);
					getArea($scope.companyFile.regionId, $scope.companyFile.areaId);
					getTime($scope.companyFile.time);
					if($scope.companyFile.style){
						$scope.imgArr = $scope.companyFile.style.split(",");
					}else {
						return;
					}
				})
			});
		};	
		//企业规模
		$scope.changeScale = function(scale) {
			$("#scale-o").hide();
			$scope.companyFile.scaleId = scale.scaleId;
		};
		
		function getscale(a) {
			$("#scale-o").hide();
			var req ={
				type:"GET",
				uri:"getScaleList",
				data:{}
			};
			httpServices.natureHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code == 0) {
						$scope.scales = data.data;
						console.log($scope.scales)
						if(!a){
							return;
						}else {
							for(var i = 0;i<$scope.scales.length;i++) {
								if(a==$scope.scales[i].scaleId) {
									$scope.scaleName = $scope.scales[i].scaleName;
								}
							}								
						}
					}else {
						alert(data.msg);
					}
				})
			});
		};
		//行业领域
		$scope.changeGuild = function(guildename) {
			$("#guild-o").hide();
			$scope.companyFile.guildId = guildename.guildId;
		};		
		function getguild(a) {
			$("#guild-o").hide();
			var req ={
				type:"GET",
				uri:"getGuildList",
				data:{}
			};
			httpServices.natureHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code == 0) {
						$scope.guilds = data.data;
						if(!a){
							return;
						}else {
							for(var i = 0;i<$scope.guilds.length;i++) {
								if(a==$scope.guilds[i].guildId) {
									$scope.guildName = $scope.guilds[i].guildName;
								}
							}								
						}						
					}else {
						alert(data.msg);
					}
				})
			});			
		};
		
		
		
		//设置时间/回显时间
		function getTime(a) {
			var newtime = new Date(a);
			$scope.year = newtime.getFullYear();
			$scope.month = newtime.getMonth()+1;
			$scope.day = newtime.getDate();

			$scope.theyear = $scope.year;
			$scope.themonth = $scope.month;
			$scope.theday = $scope.day;
		};
		setTime(1950,12,31);
		function setTime(aa,mm,dd) {
			$scope.years = [];
			$scope.months = [];
			$scope.days = [];
			var times = new Date();
			var y = times.getFullYear();

			for (var i = aa; i <= y; i++) {
				var years = {
					year:i
				}
				$scope.years.push(years);
			}
			for (var z = 1; z <= mm; z++) {
				var months = {
					month:z
				}
				$scope.months.push(months);
			}
			for (var c = 1; c <= dd; c++) {
				var days = {
					day:c
				}
				$scope.days.push(days);
			}
			$scope.years = $scope.years.reverse();
		};
		
		function settime1(dd) {
			$scope.days = [];
			for (var c = 1; c <= dd; c++) {
				var days = {
					day:c
				}
				$scope.days.push(days);
			}			
		}
		$("#option1,#option2,#option3").hide();
		$scope.yearchange = function(x) {
			if(!x)return;
			$("#option1,#option2,#option3").hide();
		};
		$scope.monthchange = function(x) {
			if(x)return console.log("xxxxx");
			var theyear = parseInt($('.select1 option:selected').text());
			
			if(x === 1||x === 3||x === 5||x === 7||x === 8||x === 10||x === 12) {
				setTime(1950,12,31);
			}
			if(x==4||x==6||x==9||x==11) {
				setTime(1950,12,30);
			}
			if(x==2){
				if ((theyear % 4 == 0) && (theyear % 100 != 0) || (theyear % 400 == 0)){
					setTime1(29);
				}else {
					setTime1(28);
				}
			}				
		};
		//点击省
		$scope.schange = function(x) {
			$("#ss,#cs,#as").hide();
			getCity(x.provinceId);
			
		};
		//点击市
		$scope.cchange = function(x) {
			$("#ss,#cs,#as").hide();
			getArea(x.regionId);
		};		
		//点击县区
		$scope.achange = function(x) {
			$("#ss,#cs,#as").hide();
		};			
		//获取省
		function getprovince(a){
			$("#ss").hide();
			var req = {
				type:'GET',
				uri:'getProvinceList'
			};
			httpServices.getshengHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code==0) {
						$scope.province = data.data;
						if(!a)return;
						for(var i = 0;i<$scope.province.length;i++) {
							if(a==$scope.province[i].provinceId) {
								$scope.provincename = $scope.province[i].provinceName;
							}
						}
					}else {
						console.log(data.msg);
					}
				});
			}).error(function(){
				console.log("省请求失败");
			});	
			
		};
		//获取城市
		function getCity(a,b) {
			$("#cs").hide();
			var req = {
				type:'GET',
				uri:'getRegionListInProvince',
				data:{
					provinceId: a
				}
			};
			httpServices.getshengHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code==0) {
						$scope.region = data.data;
						if(!b) {
							getArea($scope.region[0].regionId);
							$("#ss").hide();
							return $scope.regionname = $scope.region[0];
						}
						for(var i = 0;i<$scope.region.length;i++) {
							if(b==$scope.region[i].regionId) {
								$scope.regionname = $scope.region[i].regionName;
							}
						}
					}else {
						console.log(data.msg);
					}
				});
			}).error(function(){
				console.log("市请求失败");
			});				
		};
		
		//获取区
		function getArea(a,b) {
			$("#as").hide();
			var req = {
				type:'GET',
				uri:'getAreaListInRegionId',
				data:{
					regionId: a
				}
			};
			httpServices.getshengHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code==0) {
						$scope.areas = data.data;
						if(!b) {
							$("#cs").hide();
							$scope.areaname = $scope.areas[0];
						}
						for(var i = 0;i<$scope.areas.length;i++) {
							if(b == $scope.areas[i].areaId) {
								$scope.areaname = $scope.areas[i].areaName;
							}
						}
						
					}else {
						console.log(data.msg);
					}
				});
			}).error(function(){
				console.log("区/县请求失败");
			});				
		};
		
		//获取企业性质
		function getNature(nature){
			$("#nature-o").hide();
			var req ={
				type:"GET",
				uri:"getCompanyNatrueList",
				data:{}
			};
			httpServices.natureHttpService(req).success(function(response){
				if(!response)return;
				$scope.$apply(function(){
					$scope.companyNature = response.data;
					for(var i = 0;i < $scope.companyNature.length;i++){
						if(nature == $scope.companyNature[i].natureId){
							$scope.natureName = $scope.companyNature[i].natureName;
							return;
						}
						$scope.natureName = '';
					}
					
				})
			});
		};
		//修改企业性质
		$scope.changeNature = function(nature) {
			$("#nature-o").hide();
			$scope.companyFile.natureId = nature.natureId;
		};
		
		function getimgfy(imgSrc){
			//return  imgSrc.substr(imgSrc.indexOf("base64,")+7);
			if(imgSrc==null){return}
			if(imgSrc.indexOf("base64,")<0) {
				return imgSrc
			}else{
				return  imgSrc.substr(imgSrc.indexOf("base64,")+7,imgSrc.length)
			}
		};
		//修改企业档案
		$scope.changeInfo = function() {
			var year = $scope.year.year || $scope.year;
			var month = $scope.month.month || $scope.month;
			var day = $scope.day.day || $scope.day;
			var thetime = year+"-"+month+"-"+day;
			var thestorage = window.localStorage;
				var req = {
					type: "POST",
					uri: "modifyCompanyInfo",
					data: {
						guildId: $scope.companyFile.guildId,
						scaleId: $scope.companyFile.scaleId,
						foundTime:thetime,
						logo:getimgfy($scope.companyFile.logo),
						fullName: $scope.companyFile.fullName,
						shortName: $scope.companyFile.shortName,
						natureId: $scope.companyFile.natureId,
						provinceId: $scope.provincename.provinceId,
						regionId: $scope.regionname.regionId,
						areaId: $scope.areaname.areaId,
						address: $scope.companyFile.address,
						postcode: $scope.companyFile.postcode,
						website: $scope.companyFile.website,
						description: $scope.companyFile.description,
						introduction: $scope.companyFile.introduction,
						style: $scope.imgArr.join(","),
						legalPerson: $scope.companyFile.legalPerson,
						department: $scope.companyFile.department,
						job: $scope.companyFile.job,
						telPhone: $scope.companyFile.telPhone,
						mobilePhone: $scope.companyFile.mobilePhone,
						seed: thestorage.seed,
						authToken: thestorage.authToken
					}
				};
				$.ajax({
					type: "post",
					dataType: "json",
					data:req.data,
					url: "http://"+allUrl+":8080/elink_user/api/company/modifyCompanyInfo",
					success: function(result) {
						
						if(result.code == 0) {
							alert("修改保存成功");
							getFile();
						}else {
							alert(result.msg);
						}

								
					},
					error: function(jqXHR) {
						alert("error")
					}
				});
				
				
				
				
//				httpServices.getcompanyHttpService(req).success(function(response) {
//					if(!response)return;
//					$scope.$apply(function() {
//						if(response.code==0) {
//							console.log('修改成功！')
//						}else {
//							console.log(response.msg);
//						}
//					})
//				});
		};
		
		//判断修改的内容是否为空
		$scope.judge = function(eve) {

		};
		//寿云山结束
		//修改企业照片
		var num_id = 0;
		$scope.fileup = function($index,item) {
			var theimgdom = $(".lipicdiv")[$index];
			var theimg = $(theimgdom).children("img")[0];
			$('[type=file]').change(function(e) {
				if(this.id === item) {
					var file = e.target.files[0]
					var reader = new FileReader();
					reader.onload = function(e) {
						$(theimg).attr("src",e.target.result)
					};
					reader.readAsDataURL(file)
				} else {
					num_id++;
					var file = e.target.files[0]
					var reader = new FileReader();
					reader.onload = function(e) {
//						$("#input_id1").parent().before(
//							"<div class="+'lipicdiv'+"><label for="+num_id+"  ng-click="+'fileup($index,item)'+"></label><input id="+num_id+" type="+'file'+" style="+'visibility: hidden;'+"/><img src="+e.target.result+"/></div>"
//						);
					};
					reader.readAsDataURL(file);
				};
			});

			
		};

		//获取当前企业信息
		getcompany();
		function getcompany(){
			var req = {
				type:'GET',
				uri:'getBaseUeserInfo'
			};
			httpServices.getuserHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code==0) {
						var ph = data.data.phone;
						var pht = ph.substring(0,3);
						var phb = ph.substring(7,11);
						$scope.phone = pht+"****"+phb;
						$scope.email = data.data.email;
					}else {
						console.log(data.msg);
					}
				});
			}).error(function(){
				console.log('获取当前企业信息请求失败');
			});
			
			
		};
		
		$scope.listParams = {
            pageNo:1,
            pageSize:5
        };
		
		var begin,end;
		//改变每页条数
		$scope.changeItemsPerPage = function(item){
            $scope.listParams.pageNo = 1;
            $scope.listParams.pageSize = item;
            getCoinList(begin,end)
        }
		function getBaseInfo(){
			var req ={
			 type:"GET",
			 uri:"getBaseUeserInfo",
			 data:{}
			 };
			 httpServices.getuserHttpService(req).success(function(result){
				 $scope.$apply(function(){
				 	if(!result.data.coinValue){
				 		$scope.coinValue = 0;
				 	}else {
				 		$scope.coinValue = result.data.coinValue;
				 	}
					
				 })
			 });
		            
		}
		getBaseInfo();
		//获取E币获取记录
		function getCoinList(begin,end){
			if(begin == undefined){
				begin = "";
			}
			if(end == undefined){
				end = ""
			}
			var req = {
					type:'GET',
					uri:'getCoinList',
					data:{
						beginTime:begin,
						endTime:end,
						pageNo:1,
						pageSize:10
					}
			};
			httpServices.coinHttpService(req).success(function(response){
				$scope.$apply(function(){
					$scope.coin = response.data.list;
					$scope.totalItem = response.data.Pagination.totalCount;
                   	getListModel();
				});				
			})			
		}
		getCoinList();

		//E币获取记录跳转
		$scope.goDetail = function(item){
			if(item.typeId == 4 || item.typeId == 11 || item.typeId == 19 || item.typeId == 26 || item.typeId == 28 || item.typeId == 30){
				//跳转资料详情页
				$state.go('eng.techdetail',{fileId:item.fkId})
			}else if(item.typeId == 5 || item.typeId == 12 || item.typeId == 20 || item.typeId == 27 || item.typeId == 29 || item.typeId == 31){
				//跳转论文详情页
				$state.go('eng.libraryDetail',{thesisId:item.fkId})
			}else if(item.typeId == 6 || item.typeId == 15 || item.typeId == 21){
				//跳转企业对外
				$state.go('outIndexCtrl.homepageCtrl',{companyId:item.fkId})
			}else if(item.typeId == 7 || item.typeId == 13 || item.typeId == 22){
				//跳转视频页
				$state.go('videoPlay',{couseIdPlayId:item.fkId})
			}else if(item.typeId == 8 || item.typeId == 23){
				//跳转课程页
				$state.go('eng.vedioDetails',{courseId:item.fkId})
			}else if(item.typeId == 9 || item.typeId == 24){
				//跳转工程技能
				$state.go('eng.workDetailsCtrl',{skillId:item.fkId})
			}else if(item.typeId == 10 || item.typeId == 14 || item.typeId == 25){
				//跳转新闻页
				$state.go('eng.newsDetail',{newsId:item.fkId})
			}else if(item.typeId == 16 || item.typeId == 17 || item.typeId == 18){
				//跳转问答页
				$state.go('eng.vedioDetails',{courseId:item.fkId})
			}else if(item.typeId == 33 || item.typeId == 35 || item.typeId == 37){
				//跳转博文页 待定
				$state.go('eng.vedioDetails',{courseId:item.fkId})
			}else if(item.typeId == 32 || item.typeId == 34 || item.typeId == 36){
				//跳转职位详情页
				$state.go('zpdetailCtrl',{jobId:item.fkId})
			}
		}
		$('.three3').find('li').click(function(){
			$(this).addClass('all1').siblings().removeClass('all1')
		})
		$scope.$on('chooseDate',function(a,begin,end){
			getCoinList(begin,end)
		})
		//全部
		$scope.getCoinByDate = function(type){
			var now = new Date();                    //当前日期
		    var nowDayOfWeek = now.getDay();         //今天本周的第几天
		    var nowDay = now.getDate();              //当前日
		    var nowMonth = now.getMonth();           //当前月
		    var nowYear = now.getYear();             //当前年
		    nowYear += (nowYear < 2000) ? 1900 : 0;  //
		
		    var lastMonthDate = new Date();  //上月日期
		    lastMonthDate.setDate(1);
		    lastMonthDate.setMonth(lastMonthDate.getMonth()-1);
		    var lastYear = lastMonthDate.getYear();
		    var lastMonth = lastMonthDate.getMonth();
			if(type == 1){
				getCoinList();
				return;
			}
			if(type == 2){
				var getCurrentDate = new Date(nowYear, nowMonth, nowDay);
				var begin  = formatDate(getCurrentDate);
			}
			if(type == 3){
				//获得本周的开始日期
			    var getWeekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek);
			    var begin =  formatDate(getWeekStartDate);
			    //获得本周的结束日期
			    var getWeekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek));
			    var end =  formatDate(getWeekEndDate);
			}
			if(type == 4){
				//获得本月的开始日期
			    var getMonthStartDate = new Date(nowYear, nowMonth, 1);
			    var begin =  formatDate(getMonthStartDate);
			
			    //获得本月的结束日期
			    var getMonthEndDate = new Date(nowYear, nowMonth, getMonthDays(nowMonth));
			    var end =  formatDate(getMonthEndDate);
			}
			if(type == 5){
				//获得上月开始时间
				if(lastMonth == "12"){
					nowYear -= 1;
				}
				console.log(lastMonth,nowYear)
			    var getLastMonthStartDate = new Date(nowYear, lastMonth, 1);
			    var begin = formatDate(getLastMonthStartDate);
			
			    //获得上月结束时间
			    var getLastMonthEndDate = new Date(nowYear, lastMonth, getMonthDays(lastMonth));
			    var end = formatDate(getLastMonthEndDate);
			}
			console.log(begin,end);
			getCoinList(begin,end);
			
			
			//获得某月的天数
		    function getMonthDays(myMonth){
		        var monthStartDate = new Date(nowYear, myMonth, 1);
		        var monthEndDate = new Date(nowYear, myMonth + 1, 1);
		        var   days   =   (monthEndDate   -   monthStartDate)/(1000   *   60   *   60   *   24);
		        return   days;
		    }
		}
		
		$scope.$on('chooseDate',function(a,begin,end){
			getCoinList(begin,end)
		})
		$('.date-choose a').click(function(){
			$(this).addClass('active').siblings().removeClass();
		})
		
		//格式化日期：yyyy-MM-dd
	    function formatDate(date) {
	        var myyear = date.getFullYear();
	        var mymonth = date.getMonth()+1;
	        var myweekday = date.getDate();
			if(mymonth == 12){
				myyear -= 1;
			}
	        if(mymonth < 10){
	            mymonth = "0" + mymonth;
	        }
	        if(myweekday < 10){
	            myweekday = "0" + myweekday;
	        }
	        return (myyear+"-"+mymonth + "-" + myweekday);
	    }
	    
	    
	    function getListModel() {
			$scope.paginationConf = {
				currentPage: $scope.listParams.pageNo,
				totalItems: $scope.totalItem,
				//每页预览条数
				itemsPerPage: $scope.listParams.pageSize,
				//分页总数
				numberOfPages: Math.ceil($scope.totalItem / $scope.listParams.pageSize),
				// 实际分页长度
				pagesLength: 5,
				perPageOptions: [10, 20, 30, 40, 50],
				onChange: function(currentPage) {
					if(currentPage) {
						$scope.paginationConf.currentPage = currentPage;
					}
					$scope.list = [];
					$scope.listParams.pageNo = $scope.paginationConf.currentPage;
					getCoinList(begin,end);
				}
			};
		};
		
		
		
		
		
		
		
		
		



	})
});